#define _MODULE_ACTIONINORDER_GLOBALS
#include "Module_ActionInOrder.h"

void NodeExec(NodeHandleTypeDef *hNode)
{
	for(int i = 0;i < hNode->total;i++)
	{
		if( (NodeGetTime() > hNode->Node[i].Timestamp + hNode->StartTimestamp) && hNode->Node[i].count)
		{
			(*(void(*)(int32_t ))(hNode->Node[i].NodeOperate))(hNode->Node[i].arg);
			hNode->Node[i].count--;
		}
	}
}

void NodeDeInit(NodeHandleTypeDef *hNode)
{
	hNode->total = 0;
}

void NodeAdd(NodeHandleTypeDef *hNode,int32_t Timestamp,int32_t count,void *NodeOperate,int32_t arg)
{
	hNode->Node[hNode->total].Timestamp   = Timestamp;
	hNode->Node[hNode->total].count       = count;
	hNode->Node[hNode->total].NodeOperate = NodeOperate;
	hNode->Node[hNode->total].arg = arg;
	hNode->total++;
}
void NodeStart(NodeHandleTypeDef *hNode)
{
	hNode->StartTimestamp = NodeGetTime();
}

